from django.db import models
from django.contrib.auth.models import User

from django.utils import timezone  # 引入timezone模块

# Create your models here.


class Appointment(models.Model):
    patient = models.ForeignKey(User, on_delete=models.CASCADE, related_name='appointment_patient')
    doctor = models.ForeignKey(User, on_delete=models.CASCADE, related_name='appointment_doctor')
    appointment_time = models.DateTimeField()
    appointment_create_time = models.DateTimeField(default=timezone.now)
    appointment_description = models.TextField(max_length=1024, default='暂无症状描述')
    appointment_done=models.BooleanField(default=0)

    def __str__(self):
        return self.patient.username + ' with ' + self.doctor.username



class BookingForm(models.Model):
    form_id = models.CharField(max_length=32, primary_key=True)
    patient = models.ForeignKey(User, on_delete=models.CASCADE, related_name='book_patient')
    doctor = models.ForeignKey(User, on_delete=models.CASCADE, related_name='book_doctor')
    book_time = models.DateTimeField()
    book_description = models.TextField(max_length=1024, default='暂无症状描述')

    def __str__(self):
        return self.patient.username + ' with ' + self.doctor.username



